package  com.baomidou.springwind.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.baomidou.framework.controller.SuperController;
import com.baomidou.kisso.annotation.Action;
import com.baomidou.kisso.annotation.Login;
import com.baomidou.kisso.annotation.Permission;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.springwind.common.HoorayosHelper;
import com.baomidou.springwind.entity.Member;

/**
 *  日历控制器首页
 * @author koumiba
 * @Date 2016-04-13
 */
@Controller
@RequestMapping("/sysapp/calendar")
public class AppCalendarController extends SuperController {
	
	/**
	 * 主页
	 */
	@Login(action = Action.Skip)
	@Permission(action = Action.Skip)
	@RequestMapping("/index")
	public String index(Model model) {
		model.addAttribute("errorCode", HoorayosHelper.getErrorCodeMap());
		//验证是否登入
		if(!HoorayosHelper.checkLogin(request)){
			model.addAttribute("code", HoorayosHelper.getErrorCode("noLogin"));
			return "error";
		}
		return "/sysapp/calendar/index";
	}
	
	/**
	 * ajax页面 TODO 待完善
	 */
	@ResponseBody
	@Login(action = Action.Skip)
	@Permission(action = Action.Skip)
	@RequestMapping("/ajax")
	public String ajax() {
		String display="";
		return display;
	}
	/*************************
	 *    私有方法 
	 *************************/
	
	/**
	 * 验证是否为管理员
	 * @return Boolean
	 * koumiba
	 * 2017年3月26日
	 */
	private Boolean checkAdmin(){
		int mid = HoorayosHelper.getMemberId(request);
		EntityWrapper ew = new EntityWrapper(new Member());
		ew.setSqlSelect("type").where("where tbid="+mid);
		Member m = new Member().selectOne(ew);
		return m.getType() == 1 ? true : false;
	}
}
